<template>
	<view style="padding: 0 30rpx;">
		<back></back>
		<view class="top">
			<view class="top_one u-flex u-row-between" style="border-bottom: 1rpx solid #DFDFDF;">
				<view class="zi">提现</view>
				<view class="u-flex u-row-between" @click="$func.jump('/wNew/pages/txlist')">
					{{bank.bankName?bank.bankName:'请选择提现方式'}}
					<u-icon style="margin-left: 10rpx;" name="arrow-right"></u-icon>
				</view>
			</view>
			<view class="top_one u-flex u-row-between">
				<view class="zi">提现金额</view>
				<view class="top_gre" @click="$func.jump('/wNew/pages/withdrawalRecords')">提现记录</view>
			</view>
			<view class="int u-flex">
				<image src="../../static/wImg/money.png"></image>
				<input type="number" placeholder="输入提现金额" v-model="money">
			</view>
			<view class="tip">
				当前钱包余额剩余{{all}}元，<text @click="getAll()">全部提现</text>
			</view>
		</view>
		<view class="bottom">
			<view class="bot_tit">
				提现说明
			</view>
			<rich-text :nodes="html"></rich-text>
		</view>
		<view class="btn u-flex-center" @click="getSubmit()">
			确认提现
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bank:"",
				money:"",
				html:"",
				all:""
			}
		},
		onShow() {
			console.log(uni.getStorageSync('bank'))
			if(uni.getStorageSync('bank')){
				this.bank  = uni.getStorageSync('bank')
			}
			this.$u.post('/api/shop/get_user_tx', {}).then(res => {
				if (res.code == 1) {
					this.html =res.data.tx_sm
					this.all = res.data.money
				}
			})
		},
		methods: {
			getAll(){
				this.money = this.all
			},
			getM(){
				this.$u.post('/api/shop/get_user_tx', {}).then(res => {
					if (res.code == 1) {
						this.html =res.data.tx_sm
						this.all = res.data.money
					}
				})
			},
			getSubmit(){
				this.$u.post('/api/shop/shop_add_cash', {
					money:this.money,
					account_id:this.bank.id
				}).then(res => {
					if (res.code == 1) {
						var that = this
						that.getM()
						uni.showModal({
							title:'申请成功',
							showCancel:false,
							success() {
								uni.removeStorageSync('bank')
								
							}
						})
					}else{
						uni.showModal({
							title:res.msg,
							showCancel:false,
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.top {
		width: 100%;
		background: #FFF;
		border-radius: 10rpx;
		margin-top: 30rpx;
		padding: 0 30rpx;

		.top_one {
			padding: 30rpx 0;
		}

		.zi {
			font-size: 28rpx;
			font-weight: bold;
		}
		.top_gre{
			font-size: 24rpx;
			color: #606DCE;
		}
		.int{
			height: 120rpx;
			background: #F8F8F8;
			border-radius: 20rpx ;
			padding: 0 30rpx;
			image{
				width: 40rpx;
				height: 56rpx;
				margin-right: 30rpx;
			}
			input{
				height: 100%;
			}
		}
		.tip{
			font-size: 24rpx;
			color:#888;
			padding: 20rpx 0 47rpx 0;
			text{
				color: #606DCE;
			}
		}
	}
	.bottom{
		background: #FFFFFF;
		border-radius: 10rpx;
		margin-top: 20rpx;
		padding: 30rpx 30rpx 45rpx;
		.bot_tit{
			font-size: 28rpx;
			font-weight: bold;
			color: #222;
			margin-bottom: 20rpx;
		}
	}
	.btn{
		width: 630rpx;
		height: 80rpx;
		color:#fff;
		background: linear-gradient( 98deg, #5D64CA 0%, #6F9BDF 100%);
		border-radius: 40rpx;
		position: fixed;
		bottom: 100rpx;
		margin: 0 auto;
		left: 0;
		right: 0;
	}
</style>